package com.huawei.appgallery.forum.message.fragment;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.ScrollView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import com.huawei.appgallery.forum.message.activity.BuoyMsgSwitchSettingActivity;
import com.huawei.appgallery.forum.message.api.IBuoyMsgSwitchSettingActivityResult;
import com.huawei.appgallery.forum.message.api.IBuoyMsgSwitchSettingFragmentProtocol;
import com.huawei.appgallery.forum.message.bean.ForumMsgSettingItemCardBean;
import com.huawei.appgallery.forum.message.card.ForumBuoyMsgSwitchSettingItemCard;
import com.huawei.appgallery.forum.message.card.ForumBuoyMsgSwitchSettingItemCard.b;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.foundation.ui.framework.uikit.ContractFragment;
import com.huawei.hmf.annotation.FragmentDefine;
import java.util.ArrayList;
import java.util.List;
import o.ayy;
import o.azb;
import o.bqy;
import o.bsp;
import o.bvj;
import o.bvj.d;
import o.bvj.e;
import o.bvj.j;
import o.bvo;
import o.epv;
import o.fjf;
import o.fjm;

@FragmentDefine(alias = "buoy_msg_setting_fragment", protocol = IBuoyMsgSwitchSettingFragmentProtocol.class)
public class BuoyMsgSwitchSettingFragment extends ContractFragment implements b {
    private bvo ʼ;
    private List<ForumMsgSettingItemCardBean> ʽ = new ArrayList();
    private LinearLayout ˊ;
    private fjm ˋ = fjm.ॱ(this);
    private ImageView ˎ;
    private RelativeLayout ˏ;
    private IBuoyMsgSwitchSettingFragmentProtocol ॱ;
    private ScrollView ॱॱ;
    private Handler ᐝ = new Handler();

    public void ˏ(@Nullable Bundle bundle) {
        boolean z = true;
        c_(true);
        super.ˏ(bundle);
        this.ॱ = (IBuoyMsgSwitchSettingFragmentProtocol) this.ˋ.ॱ();
        if (this.ॱ == null) {
            Activity ॱˋ = ॱˋ();
            if (ॱˋ != null) {
                ॱˋ.finish();
                return;
            }
            return;
        }
        boolean z2;
        this.ʼ = new bvo();
        this.ʼ.ˎ(this.ॱ.getReplyMsgSwitch() == 1);
        bvo o_bvo = this.ʼ;
        if (this.ॱ.getLikeMsgSwitch() == 1) {
            z2 = true;
        } else {
            z2 = false;
        }
        o_bvo.ˊ(z2);
        o_bvo = this.ʼ;
        if (this.ॱ.getFollowMsgSwitch() == 1) {
            z2 = true;
        } else {
            z2 = false;
        }
        o_bvo.ॱ(z2);
        o_bvo = this.ʼ;
        if (this.ॱ.getImportantMsgSwitch() == 1) {
            z2 = true;
        } else {
            z2 = false;
        }
        o_bvo.ˏ(z2);
        o_bvo = this.ʼ;
        if (this.ॱ.getGrowthMsgSwitch() == 1) {
            z2 = true;
        } else {
            z2 = false;
        }
        o_bvo.ˋ(z2);
        o_bvo = this.ʼ;
        if (this.ॱ.getPushMsgSwitch() == 1) {
            z2 = true;
        } else {
            z2 = false;
        }
        o_bvo.ॱॱ(z2);
        bvo o_bvo2 = this.ʼ;
        if (this.ॱ.getReviewMsgSwitch() != 1) {
            z = false;
        }
        o_bvo2.ʻ(z);
        ʼᐝ();
    }

    @Nullable
    public View ˋ(@NonNull LayoutInflater layoutInflater, @Nullable ViewGroup viewGroup, @Nullable Bundle bundle) {
        int i;
        if (bsp.ˋ()) {
            i = e.ॱॱ;
        } else {
            i = e.ˎ;
        }
        View inflate = layoutInflater.inflate(i, viewGroup, false);
        this.ॱॱ = (ScrollView) inflate.findViewById(bvj.b.ʼॱ);
        this.ˏ = (RelativeLayout) inflate.findViewById(bvj.b.ˋˊ);
        this.ˎ = (ImageView) inflate.findViewById(bvj.b.ʾ);
        this.ˊ = (LinearLayout) inflate.findViewById(bvj.b.ʿ);
        this.ᐝ.post(new Runnable(this) {
            final /* synthetic */ BuoyMsgSwitchSettingFragment ॱ;

            {
                this.ॱ = r1;
            }

            public void run() {
                this.ॱ.ॱ();
                this.ॱ.ʽᐝ();
            }
        });
        return inflate;
    }

    private void ॱ() {
        LayoutParams layoutParams = (LayoutParams) this.ˎ.getLayoutParams();
        LinearLayout.LayoutParams layoutParams2 = (LinearLayout.LayoutParams) this.ˏ.getLayoutParams();
        Context ˏ = bqy.ˋ().ˏ();
        int ॱ;
        if (bsp.ˋ()) {
            int ˊ = epv.ˊ(ˏ) / 2;
            ॱ = (epv.ॱ(ˏ) - epv.ॱ()) - ˏ.getResources().getDimensionPixelSize(d.ͺ);
            layoutParams2.height = ॱ;
            layoutParams2.width = ˊ;
            if (this.ॱॱ != null) {
                if (ayy.ˋ().ˎ()) {
                    this.ॱॱ.setPadding(0, 0, 0, ayy.ˋ().ˊ());
                } else {
                    this.ॱॱ.setPadding(0, 0, 0, 0);
                }
                ((LinearLayout.LayoutParams) this.ॱॱ.getLayoutParams()).height = ॱ;
                return;
            }
            return;
        }
        ॱ = azb.ॱ(ˏ);
        layoutParams.width = ॱ;
        layoutParams.height = ॱ;
        layoutParams2.height = ॱ;
        layoutParams2.width = ॱ;
    }

    private void ʽᐝ() {
        if (this.ʽ.size() == 0 && this.ʼ != null) {
            this.ʽ.add(ˏ(1, j.ᐝˊ, this.ʼ.ˎ()));
            this.ʽ.add(ˏ(2, j.ᐧ, this.ʼ.ˏ()));
            this.ʽ.add(ˏ(3, j.ـ, this.ʼ.ˋ()));
            this.ʽ.add(ˏ(4, j.ᐝˋ, this.ʼ.ˊ()));
            this.ʽ.add(ˏ(5, j.ॱʻ, this.ʼ.ॱ()));
            this.ʽ.add(ˏ(6, j.ॱͺ, this.ʼ.ᐝ()));
            ForumMsgSettingItemCardBean ˏ = ˏ(7, j.ॱʽ, this.ʼ.ʼ());
            ˏ.ˊ(0);
            this.ʽ.add(ˏ);
        }
        LayoutInflater from = LayoutInflater.from(ॱˊ());
        for (ForumMsgSettingItemCardBean ˏ2 : this.ʽ) {
            ForumBuoyMsgSwitchSettingItemCard forumBuoyMsgSwitchSettingItemCard = new ForumBuoyMsgSwitchSettingItemCard(ॱˊ());
            RelativeLayout relativeLayout = (RelativeLayout) from.inflate(e.ʽ, null);
            forumBuoyMsgSwitchSettingItemCard.ˏ((View) relativeLayout);
            this.ˊ.addView(relativeLayout);
            forumBuoyMsgSwitchSettingItemCard.ˏ((CardBean) ˏ2);
            forumBuoyMsgSwitchSettingItemCard.ˋ((b) this);
        }
    }

    private ForumMsgSettingItemCardBean ˏ(int i, int i2, boolean z) {
        ForumMsgSettingItemCardBean forumMsgSettingItemCardBean = new ForumMsgSettingItemCardBean();
        forumMsgSettingItemCardBean.ˏ(i);
        forumMsgSettingItemCardBean.ˎ(i2);
        forumMsgSettingItemCardBean.ˎ(z);
        return forumMsgSettingItemCardBean;
    }

    public void ˎ(int i, boolean z) {
        if (this.ʼ != null) {
            switch (i) {
                case 1:
                    this.ʼ.ˎ(z);
                    break;
                case 2:
                    this.ʼ.ˊ(z);
                    break;
                case 3:
                    this.ʼ.ॱ(z);
                    break;
                case 4:
                    this.ʼ.ˏ(z);
                    break;
                case 5:
                    this.ʼ.ˋ(z);
                    break;
                case 6:
                    this.ʼ.ॱॱ(z);
                    break;
                case 7:
                    this.ʼ.ʻ(z);
                    break;
            }
            ʼᐝ();
        }
    }

    private void ʼᐝ() {
        Activity ॱˋ = ॱˋ();
        if (ॱˋ instanceof BuoyMsgSwitchSettingActivity) {
            fjf ˊ = fjf.ˊ(ॱˋ);
            ((IBuoyMsgSwitchSettingActivityResult) ˊ.ॱ()).setMsgSetting(this.ʼ);
            ॱˋ.setResult(-1, ˊ.ˊ());
        }
    }
}
